/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package eproject_sem2;

import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author ZER0
 */
public class Edit_Passwrod_Sever {

    String user = ConnectSQL.user;
    String pass = ConnectSQL.pass;
    String ulr =ConnectSQL.ulr;
    String DriverClass =ConnectSQL.DriverClass;
    Connection con = null;

    public boolean UpdatePrice(String idu, String username, String pass1, String table, String cn1, String cn3, String cn4) {
        boolean kq = true;
        try {
            Class.forName(DriverClass);
            con = DriverManager.getConnection(ulr, user, pass);
            String sql = "update " + table + " set  " + cn4 + " ='" + pass1 + "' where  " + cn1 + "='" + idu + "'and " + cn3 + "='" + username + "'";
            PreparedStatement ps = con.prepareStatement(sql);
            ps.executeUpdate();
            kq = false;
            System.out.println("asdas");
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Edit_Passwrod_Sever.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
        return kq;
    }

    public String CheckUSer(String u, String password) {
        String kq = null;
        try {

            Class.forName(DriverClass);
            con = DriverManager.getConnection(ulr, user, pass);
            String sql3 = "select * from Users where Username='" + u + "' and Password='" + password + "'";
            Statement st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
            ResultSet rs = st.executeQuery(sql3);
            while (rs.next()) {
                kq = rs.getString(3);
            }
        } catch (SQLException ex) {
            Logger.getLogger(Edit_Passwrod_Sever.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Edit_Passwrod_Sever.class.getName()).log(Level.SEVERE, null, ex);
        }
        return kq;
    }
}
